package com.wanban.txplayertest

import android.app.Application
import com.rabbit.videoplayer.MixPlayerView
import com.rabbit.videoplayer.response.PlayerType
import com.wanban.downloader.MultiDownloadManager
import com.wanban.downloader.db.DownloadEntity
import com.wanban.downloader.listener.OnDownloadListener
import com.wanban.downloader.model.DownloadType
import org.greenrobot.eventbus.EventBus


class MyApplication: Application() {

    companion object {
        // 定义全局的Application
        lateinit var context: Application
    }


    override fun onCreate() {
        super.onCreate()
        context = this

        // 初始化播放器
        MixPlayerView.initPlayer(this, PlayerType.ALIYUN, isUseTX = true, isUseAli = true)


        MultiDownloadManager.init(this, DownloadType.SELF, object: OnDownloadListener {
            override fun onDownloadStatusChanged(task: DownloadEntity) {
                EventBus.getDefault().post(task)
            }
        }) { hasDownloadingTask ->

        }.setMaxDownloadQueueCount(3).setMaxThreadNumber(3)
    }

}